package com.project.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.project.bean.SupplierBean;
import com.project.mapper.ISupplierMapper;
import com.project.service.ISupplierService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("Supplier")
public class SupplierController {
    @Autowired
    private ISupplierService supplierService;

    @RequestMapping("findByItem")
    public IPage<SupplierBean> findByItem(Integer pageNO, String name, String manage) {
        return supplierService.findByItem(pageNO, name, manage);
    }

    @RequestMapping("add")
    public String add(SupplierBean supplierBean) {
        supplierService.add(supplierBean);
        return "ok";
    }

    @RequestMapping("findById")
    public SupplierBean findById(Integer id) {
        return supplierService.findById(id);
    }

    @RequestMapping("update")
    public String update(Integer id, String principal, String phone) {
        supplierService.update(id, principal, phone);
        return "ok";
    }

    @RequestMapping("find")
    public List<SupplierBean> find() {
        return supplierService.find();
    }

    @RequestMapping("addList")
    public void addList(List<SupplierBean> supplierList) {
        supplierService.addList(supplierList);
    }
}
